CFLAGS = -fpic -coverage -lm -std=c99 


rngs.o: rngs.h rngs.c
	gcc -c rngs.c -g  $(CFLAGS)

dominion.o: dominion.h dominion.c rngs.o
	gcc -c dominion.c -g  $(CFLAGS)  

playdom: dominion.o playdom.c
	gcc -o playdom playdom.c -g dominion.o rngs.o $(CFLAGS)
	
randomtestcard: randomtestcard.c dominion.o rngs.o dominion.h
	gcc -o randomtestcard -g  randomtestcard.c dominion.o rngs.o $(CFLAGS)

randomtestadventurer: randomtestadventurer.c dominion.o rngs.o dominion.h
	gcc -o randomtestadventurer -g  randomtestadventurer.c dominion.o rngs.o $(CFLAGS)


testDrawCard: testDrawCard.c dominion.o rngs.o
	gcc -o testDrawCard -g  testDrawCard.c dominion.o rngs.o $(CFLAGS)

badTestDrawCard: badTestDrawCard.c dominion.o rngs.o
	gcc -o badTestDrawCard -g  badTestDrawCard.c dominion.o rngs.o $(CFLAGS)

testBuyCard: testDrawCard.c dominion.o rngs.o
	gcc -o testDrawCard -g  testDrawCard.c dominion.o rngs.o $(CFLAGS)

testAll: dominion.o testSuite.c
	gcc -o testSuite testSuite.c -g  dominion.o rngs.o $(CFLAGS)  

interface.o: interface.h interface.c
	gcc -c interface.c -g  $(CFLAGS)

runtests: testDrawCard 
	./testDrawCard &> unittestresult.out
	gcov dominion.c >> unittestresult.out
	cat dominion.c.gcov >> unittestresult.out

player: player.c interface.o
	gcc -o player player.c -g  dominion.o rngs.o interface.o $(CFLAGS)
	
unittest1: unittest1.c dominion.o rngs.o
	gcc -o unittest1 -g unittest1.c dominion.o rngs.o -lgcov $(CFLAGS)   

unittest2.o: unittest2.c dominion.c rngs.c dominion.h
	gcc -c unittest2.c dominion.h -g     $(CFLAGS)  

unittest2 : unittest2.o dominion.o rngs.o
	gcc -o unittest2 -g unittest2.o dominion.o rngs.o    $(CFLAGS)

unittest3: unittest3.c dominion.o rngs.o
	gcc -o unittest3 -g unittest3.c dominion.o rngs.o  $(CFLAGS)  
	
unittest4: unittest4.c dominion.o rngs.o
	gcc -o unittest4 -g unittest4.c dominion.o rngs.o  $(CFLAGS)  
 	
randomtestcard.out: randomtestcard dominion.o rngs.o 
	./randomtestcard >> randomtestcard.out
	gcov dominion.c >> randomtestcard.out
	cat dominion.c.gcov >> randomtestcard.out

randomtestadventurer.out: randomtestadventurer dominion.o rngs.o
	./randomtestadventurer >> randomtestadventurer.out
	gcov dominion.c >> randomtestadventurer.out
	cat dominion.c.gcov >> randomtestadventurer.out
	
unittestresults.out: unittest4.o dominion.o rngs.o unittest3.o unittest2.o unittest1.o
	./unittest1 >> unittestresults.out
	gcov dominion.c >> coverage1.out
	cat dominion.c.gcov >> coverage1.out
	./unittest2 >> unittestresults.out
	gcov dominion.c >> coverage2.out
	cat dominion.c.gcov >> coverage2.out
	./unittest3 >> unittestresults.out
	gcov dominion.c >> coverage3.out
	cat dominion.c.gcov >> coverage3.out
	./unittest4 >> unittestresults.out
	gcov dominion.c >> coverage4.out
	cat dominion.c.gcov >> coverage4.out
        
all: playdom player testDrawCard testBuyCard badTestDrawCard unittest1 unittest2 unittest3 unittest4 unittestresults.out unittest1.o unittest2.o unittest3.o unittest4.o randomtestcard randomtestadventurer

clean:
	rm -f *.o playdom.exe playdom test.exe test player player.exe testInit testInit.exe unittest1.exe *.gcov *.gcda *.gcno *.so *.out
